package method.Threads;

public class ThreadRedPacket implements Runnable{
    RedPacket rp=new RedPacket();

    @Override
    public void run() {
        if (rp.balance>0){
            System.out.println(Thread.currentThread().getName()+"准备抢红包");
            rp.operation(10);
            System.out.println(Thread.currentThread().getName()+"抢到10元");
            System.out.println("红包余额为"+rp.balance);

        }else {
            System.out.println(Thread.currentThread().getName()+"抢红包失败，红包已被领取完毕。");
        }
    }
}
